<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib  uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<metaname="viewport"content="width=device-width, initial-scale=1.0">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="/resource/css/bootstrap.min.css" />
<script type="text/javascript" src="/resource/js/jquery-3.2.1.js"></script>
<script type="text/javascript" src="/resource/js/bootstrap.min.js"></script>
<script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.js"></script>
</head>
<body>
	<div class="container-fluid">
	
	<div>
		<!-- 生成订单的数据 -->
		<fieldset>
			<label for="address">配送地址</label>
			<textarea id="address" rows="3" cols="50">
				
			</textarea>
		</fieldset>
		<button type="button" onclick="createOrder()">下单</button>
	</div>
	<!-- 查询结果 -->
	 <div>
	 	<table class="table">
	 		<tr>
	 			<th>id <input id="ids" type="checkbox"></th>
	 			<th>标题</th>
	 			<th>价格</th>
	 			<th>购买数量</th>
	 			<th>总价格</th>
	 			<th>图片</th>
	 			<th>操作</th>
	 		</tr>
	 		<c:forEach items="${cartList}" var="cart">
	 			<tr>
	 			
	 				<td>${cart.id}
	 					<input type="checkbox" value="${cart.id}" name="id">
	 				</td>
	 			 <td>${cart.sku.title}</td> 
	 				<td>${cart.sku.price}</td>
	 				<td>${cart.pnum}</td>
	 				<td>${cart.pnum*cart.sku.price}</td>
	 				<td><img src="/pic/${cart.sku.cartThumbnail}" width="40" height="40"></td>
	 				<td>
						<button type="button" class="btn btn-warning btn-sm" onclick="toUpdate(${sku.id})">修改</button>
	 				</td>
	 			</tr>
	 		</c:forEach>
	 	</table>
	 </div>
</div>  
</body>
<script type="text/javascript">
     function toAdd(){
	   $("#workContent").load('./spu/toadd');
      }


    function del(ids){
	
	 if(!confirm('确认删除么？'))
		return;
	
	 $.post('./user/delCart',{ids:ids},function(data){
		 if(data=='ok'){
			alert('删除成功')
			//刷新
			query("${pageInfo.pageNum}")
		  }else{
			alert('删除失败')
		  }
		
	   })
    }





    function query(page){
	     var query = $("#queryForm").serialize();
	      $("#workContent").load('./sku/list?pageNum='+page,query);
			
         }
</script>
</html>